clear

set scheme plotplain

use Data_Proc\recs_clean

* MARKET SHARE BY VINTAGE SEPARATELY FOR EACH HEATING TECHNOLOGY
foreach v of varlist hp elec ngas prop kero wood {
	foreach y of numlist 2009 2015 2020 {
		local hlabel : variable label `v'
		reg `v' i.vintage if recs==`y' & heat==1 [pw=nweight], robust noconstant
		estimates store reg_`y'
		}
		coefplot ///
			(reg_2009, 	c(l) offset(-0.01) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(dash) label("2009")) ///
			(reg_2015, 	c(l) offset(-0.03) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(solid) label("2015")) ///
			(reg_2020, 	c(l) offset(-0.05) msymbol(o) mc(black) lc(black) ciopts(color(gray)) lp(solid) label("2020")), ///
			vert keep(*.vintage) msize(vsmall) legend(position(0) bplacement(n) cols(3) symx(13)) ytitle("`hlabel' share")
		graph export Final_Output\fig_share_vintage_`v'.png, as(png) replace
		estimates clear
}

* CHANGE IN MARKET SHARE BY RECS FOR ALL HEATING TECHNOLOGIES (RELATIVE TO 2005)
foreach v of varlist hp elec ngas prop kero wood {
		reg `v' recs2009 recs2015 recs2020 i.vintage if heat==1  & vintage<=1990 & recs>=2005 [pw=nweight], robust
		estimates store reg_`v'

}
coefplot ///
		(reg_hp, 	c(l) offset(-0.05) msymbol(o) mc(black) lc(black) ciopts(color(gray)) lp(solid) label("HP")) ///
		(reg_ngas, 	c(l) offset(-0.03) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(shortdash) label("Gas")) ///
		(reg_elec, 	c(l) offset(-0.01) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(solid) label("Elec")) ///
		(reg_kero, 	c(l) offset( 0.01) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(dash) label("Oil")) ///
		(reg_prop, 	c(l) offset( 0.03) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(longdash) label("Prop")) ///
		(reg_wood, 	c(l) offset( 0.05) msymbol(o) mc(gray) lc(gray) ciopts(color(gray)) lp(dot) label("Wood")), ///
		vert keep(recs2009 recs2015 recs2020) msize(vsmall) legend(position(0) bplacement(n) cols(3) symx(13)) ylabel(-.1(.05).1) ytitle("Change in share")
graph export Final_Output\fig_dshare_recs_allheat.png, as(png) replace
estimates clear


clear
exit


